import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:industry_net/base/common/colors_util.dart';
import 'package:industry_net/base/common/size_fit.dart';
import 'package:industry_net/base/component/list/refresh.dart';
import 'package:industry_net/base/component/list/table_view.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'controller.dart';
import 'views/header.dart';

class HomePage extends StatelessWidget {
  HomePage({Key? key}) : super(key: key);
  final HomeController controller = Get.put(HomeController());
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ColorsUtil.white,
      body: Stack(
        children: [
          TableView(
            separatorIndent: gap12,
            controller: controller.state.scrollController,
            header: const HomeHeader(),
            data: controller.state.newsSource,
            refreshController: controller.state.refreshCtrl,
            onRefresh: controller.onRefresh,
            onLoading: controller.onLoading,
            refreshTopInset: SizeFit.statusBarHeight,
          ),
          Positioned(
            height: SizeFit.statusBarHeight + 44,
            width: Get.width,
            child: HomeAppBar(),
          ),
        ],
      ),
    );
  }
}
